package liuch.JMS;

import org.apache.activemq.ActiveMQConnectionFactory;

import javax.jms.*;

/**
 * @author 17101651
 * @ClassName ActiveMQSenderTest
 * @Description activeMq消息中间件消息发送端，前提需要先启动activeMQ
 * @data 2018年08月17日
 */
public class ActiveMQSenderTest {
    public static void main(String[] args) throws JMSException {
        ConnectionFactory connectionFactory = new ActiveMQConnectionFactory();
        Connection connection = connectionFactory.createConnection();
        Session session = connection.createSession(Boolean.TRUE,Session.AUTO_ACKNOWLEDGE);
        Queue queue = session.createQueue("lch-queue");
        MessageProducer messageProducer = session.createProducer(queue);
        TextMessage textMessage = session.createTextMessage("243");
        messageProducer.send(textMessage);
        session.commit();
        session.close();
        connection.close();
    }
}
